package io.gitee.cloudladder.obsidian.swagger2.example.controller;

import io.gitee.cloudladder.obsidian.swagger2.annotation.ApiOperationSort;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.BaseDataTypeParamObject;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.ExtendDataTypeParamObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(value = "Test Header Parameter Controller")
@RestController
public class TestHeaderParameterController {

    @ApiOperationSort(0)
    @PostMapping("/test/header/boolean")
    public void testHeaderBoolean(@RequestHeader Boolean param) {
        log.info("testHeaderBoolean: param = {}", param);
    }

    @ApiOperationSort(1)
    @PostMapping("/test/header/string")
    public void testHeaderString(@RequestHeader String param) {
        log.info("testHeaderString: param = {}", param);
    }

    @ApiOperationSort(2)
    @PostMapping("/test/header/byte")
    public void testHeaderByte(@RequestHeader Byte param) {
        log.info("testHeaderByte: param = {}", param);
    }

    @ApiOperationSort(3)
    @PostMapping("/test/header/short")
    public void testHeaderShort(@RequestHeader Short param) {
        log.info("testHeaderShort: param = {}", param);
    }

    @ApiOperationSort(4)
    @PostMapping("/test/header/integer")
    public void testHeaderInteger(@RequestHeader Integer param) {
        log.info("testHeaderInteger: param = {}", param);
    }

    @ApiOperationSort(5)
    @PostMapping("/test/header/long")
    public void testHeaderLong(@RequestHeader Long param) {
        log.info("testHeaderLong: param = {}", param);
    }

    @ApiOperationSort(6)
    @PostMapping("/test/header/float")
    public void testHeaderFloat(@RequestHeader Float param) {
        log.info("testHeaderFloat: param = {}", param);
    }

    @ApiOperationSort(7)
    @PostMapping("/test/header/double")
    public void testHeaderDouble(@RequestHeader Double param) {
        log.info("testHeaderDouble: param = {}", param);
    }

    @ApiOperationSort(8)
    @PostMapping("/test/header/date")
    @ApiOperation(value = "testHeaderDate", notes = "'yyyy-MM-dd hh:mm:ss' is supported")
    public void testHeaderDate(@RequestHeader Date param) {
        log.info("testHeaderDate: param = {}", param);
    }

    @ApiOperationSort(9)
    @PostMapping("/test/header/localDate")
    @ApiOperation(value = "testHeaderLocalDate", notes = "'yyyy-MM-dd' is supported")
    public void testHeaderLocalDate(@RequestHeader LocalDate param) {
        log.info("testHeaderLocalDate: param = {}", param);
    }

    @ApiOperationSort(10)
    @PostMapping("/test/header/array/string")
    @ApiOperation(value = "testHeaderArrayString", notes = "'a, b' is supported")
    public void testHeaderArrayString(@RequestHeader String[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testHeaderArrayString: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(11)
    @PostMapping("/test/header/array/integer")
    @ApiOperation(value = "testHeaderArrayInteger", notes = "'1, 2' is supported")
    public void testHeaderArrayInteger(@RequestHeader Integer[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testHeaderArrayInteger: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(12)
    @PostMapping("/test/header/list/string")
    @ApiOperation(value = "testHeaderListString", notes = "'a, b' is supported")
    public void testHeaderListString(@RequestHeader List<String> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testHeaderListString: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(13)
    @PostMapping("/test/header/list/integer")
    @ApiOperation(value = "testHeaderListInteger", notes = "'1, 2' is supported")
    public void testHeaderListInteger(@RequestHeader List<Integer> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testHeaderListInteger: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(14)
    @PostMapping("/test/header/object/base")
    public void testFormObjectBase(@ModelAttribute BaseDataTypeParamObject params) {
        log.info("testFormObjectBase: param = {}", params);
    }

}

